package com.mall4j.cloud.order.application.service;

import com.mall4j.cloud.order.application.cmd.CreateOrderCmd;
import com.mall4j.cloud.order.domain.entity.Order;
import com.mall4j.cloud.order.domain.repository.OrderRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class OrderAppService {

    @Resource
    OrderRepository orderRepository;

    /**
     * 下单
     * @param createOrderCmd
     */
    public void submitOrder(CreateOrderCmd createOrderCmd){
        Order order = Order.builder()
                .userId(createOrderCmd.getUserId())
                .shopId(createOrderCmd.getShopId())
                .total(createOrderCmd.getPrice())
                .build();
        order.createOrder();
        orderRepository.save(order);
    }
}
